package n2247;

import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	
	static int a[]=new int[5842];
	
	static int p[]={0,0,0,0};
	
	static int v[]={2,3,5,7};
	static void init()
	{
		a[0]=1;
		for(int i=1;i<5842;i++)
		{
			int min=a[p[0]]*v[0];
			for(int j=1;j<4;j++)
			{
				if(min>a[p[j]]*v[j])
				{
					min=a[p[j]]*v[j];
				}
			}
			for(int j=0;j<4;j++)
			{
				if(a[p[j]]*v[j]==min)
				{
					p[j]=p[j]+1;
				}
			}
			a[i]=min;
		}
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub

		init();
		
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		String line=null;
		while((line=bf.readLine())!=null)
		{
			int n=Integer.parseInt(line);
			if(n==0)break;
			if(n%10==1&&n%100!=11)   
	           System.out.println("The "+n+"st humble number is "+a[n-1]+".");  
	        else if(n%10==2&&n%100!=12)   
			System.out.println("The "+n+"nd humble number is "+a[n-1]+".");
	        else if(n%10==3&&n%100!=13)   
			System.out.println("The "+n+"rd humble number is "+a[n-1]+".");
	        else   
			System.out.println("The "+n+"th humble number is "+a[n-1]+".");
		}
		
	}

}
